package com.ktjiaoyu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ktjiaoyu.mapper.SysUserMapper;
import com.ktjiaoyu.pojo.SysUser;
import com.ktjiaoyu.service.SysUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysUserServiceImpl implements SysUserService {
    @Resource
    SysUserMapper sysUserMapper;

    @Override
    public int addUser(SysUser sysUser) {
        return sysUserMapper.insert(sysUser);
    }

    @Override
    public int updateUser(SysUser sysUser) {
        return sysUserMapper.updateById(sysUser);
    }

    @Override
    public int deleteUser(Long id) {
        return sysUserMapper.deleteById(id);
    }

    @Override
    public SysUser getUser(Long id) {
        return sysUserMapper.selectById(id);
    }

    @Override
    public List<SysUser> findAllUsers() {
        return sysUserMapper.selectList(null);
    }

    @Override
    public SysUser login(String usrName, String usrPassword) {
        QueryWrapper<SysUser> qw=new QueryWrapper<>();
        qw.eq("usr_name",usrName);
        qw.eq("usr_password",usrPassword);

        return sysUserMapper.selectOne(qw);
    }
}
